﻿// pch.h: 这是预编译标头文件。
// 下方列出的文件仅编译一次，提高了将来生成的生成性能。
// 这还将影响 IntelliSense 性能，包括代码完成和许多代码浏览功能。
// 但是，如果此处列出的文件中的任何一个在生成之间有更新，它们全部都将被重新编译。
// 请勿在此处添加要频繁更新的文件，这将使得性能优势无效。

#ifndef PCH_H
#define PCH_H



// 添加要在此处预编译的标头
#include "framework.h"


#define MT318_API  extern "C" _declspec(dllexport) 

#define YICT_ERROR_UNKNOWN					-777;
#define YICT_ERROR_DLL_NOT_FOUND			-888;
#define YICT_ERROR_DEVICE_PORT				-777;
#define YICT_ERROR_KEY						-666;
#define YICT_ERROR_LOAD_KEYA				-333;
#define YICT_ERROR_LOAD_KEYB				-222;
#define YICT_ERROR_NO_REMOVE_CARD           -3;
#define YICT_ERROR_FIND_M1                  2;

#define YICT_SUCC							0;
#define YICT_SUCC_READ_CARD					1;
#define YICT_ERROR_READ_CARD				4;
#define YICT_ERROR_CARD_NOT_FOUND			2;
#define YICT_ERROR_SELECT_CARD				3;

#define YICT_SUCC_WRITE_CARD				1;
#define YICT_ERROR_WRITE_CARD				-998;

typedef int(WINAPI *CVR_InitComm)(int);
typedef int(WINAPI *CVR_CloseComm)();
typedef int(WINAPI *CVR_Authenticate)();
typedef int(WINAPI *CVR_Read_Content)(int);
typedef int(WINAPI *GetPeopleName)(char*, int*);
typedef int(WINAPI *GetPeopleIDCode)(char*, int*);

typedef int(WINAPI  *rf_init_def)(int port, long baud);
typedef int(WINAPI  *rf_exit_def)(int icdev);
typedef int(WINAPI  *rf_load_key_def)(int icdev, unsigned char _Mode, unsigned char _SecNr, unsigned char *_NKey);
typedef int(WINAPI  *rf_card_def)(int icdev, unsigned char _Mode, unsigned long *_Snr);
typedef int(WINAPI  *rf_read_def)(int icdev, unsigned char _Adr, unsigned char *_Data);
typedef int(WINAPI  *rf_authentication_def)(int icdev, unsigned char _Mode, unsigned char _SecNr);
typedef int(WINAPI  *rf_halt_def)(int icdev);
typedef int(WINAPI  *rf_beep_def)(int icdev, unsigned short _Msec);

extern "C" _declspec(dllexport) int ForceReconnect();
extern "C" _declspec(dllexport) int GetIDCardInfo(int port, char* name, int* name_len, char* idcode, int* idcode_len);
extern "C" _declspec(dllexport) int GetICCardInfo(char* card_id, int* card_id_len, char* permit_no, int* permit_no_len, char* resu);
extern "C" _declspec(dllexport) void getDevices(char* devs);
extern "C" _declspec(dllexport) int WriteCard(unsigned char* p8, unsigned char* p9, char* resu);
extern "C" _declspec(dllexport) int ReadCard(char* p8, int* p8_len, char* p9, int* p9_len, char* resu);
extern "C" _declspec(dllexport) int GetICCardInfoNotHalt(char* card_id, int* card_id_len, char* permit_no, int* permit_no_len, char* resu);

//MT318读卡器用函数声明
extern HANDLE hPort;
extern "C" _declspec(dllexport) int MT318_ComOpen(int ComNum);
extern "C" _declspec(dllexport) int MT318_ComClose();
MT318_API DWORD MT318_ComRead(unsigned char * buf, DWORD size);
MT318_API DWORD MT318_ComReadSyn(unsigned char *buf, DWORD wCount, DWORD wWaitTickCount);
MT318_API DWORD MT318_ComWrite(TCHAR *buf, DWORD dwCharToWrite);
MT318_API BOOL MT318_InitCommTimeouts();
MT318_API BOOL MT318_InitDCB(DWORD baudRate, BYTE byteSize, BYTE parity, BYTE stopBits);
//与读卡器操作相关的函数
MT318_API DWORD MT318_GetCardInfo(unsigned char* Data);   //获取卡版本信息
MT318_API DWORD MT318_DESELECT(unsigned char* Data);      //DESELECT
MT318_API DWORD MT318_FindM1(unsigned char* Data);        //寻找射频M1卡
MT318_API DWORD MT318_FindMifare1(unsigned char* Data);    //获取Mifare1卡序列号
MT318_API DWORD MT318_CheckKeyA(unsigned char* RetrunData, unsigned char SectionNum, unsigned char *Key);
MT318_API DWORD MT318_CheckKeyB(unsigned char* RetrunData, unsigned char SectionNum, unsigned char *Key);
MT318_API DWORD MT318_WriteSection(unsigned char* Data, unsigned char* DataNew, unsigned char SectionNum, unsigned char Num);
MT318_API DWORD MT318_ReadSection(unsigned char* Data, unsigned char SectionNum, unsigned char Num); //读扇区数据
#endif //PCH_H
